<div class="bjui-pageContent">
    <form action="/admin/personnel/address-list-member-edit" data-toggle="ajaxform" data-options="{
        closeCurrent: true,
        okAfterCallback: refreshAddressList,
        beforeSubmit: checkAddressListMemberData
    }">
        <input type="hidden" name="employee_id" value="{{ $employeeInfo['id'] }}">
        <div class="bjui-row col-3">
            <div class="panel">
                <label class="row-label" style="width: 150px">姓名:</label>
                <div class="row-input required" style="width:200px">
                    <input type="text" name="name" value="{{ $employeeInfo['name'] }}" data-rule="required;length[~10]">
                </div>
                <label class="row-label" style="width: 150px">性别:</label>
                <div class="row-input required" style="width:200px">
                    <select data-toggle="selectpicker" id="sex" name="sex">
                        <option value="">请选择</option>
                        <option value="1" @if($employeeInfo['sex'] == 1) selected @endif>男</option>
                        <option value="2" @if($employeeInfo['sex'] == 2) selected @endif>女</option>
                    </select>
                </div>
                <label class="row-label" style="width: 150px">角色:</label>
                <div class="row-input required" style="width:200px">
                    <select data-toggle="selectpicker" id="role_name" name="role_id">
                        <option value="">请选择</option>
                        @foreach($roleList as $role)
                            <option value="{{$role['id']}}"
                                    @if($employeeInfo['role_id'] == $role['id']) selected @endif >{{$role['display_name']}}</option>
                        @endforeach
                    </select>
                </div>
                <br/>
                <label class="row-label" style="width: 150px">籍贯:</label>
                <div class="row-input required" style="width:200px">
                    <input type="text" name="birthplace" value="{{ $employeeInfo['birthplace'] }}" data-rule="required">
                </div>
                <label class="row-label" style="width: 150px">生日:</label>
                <div class="row-input required" style="width:200px">
                    <input type="text" name="birthdate" data-toggle="datepicker"
                           value="{{ $employeeInfo['birthdate'] }}"
                           data-rule="required" placeholder="点击日历选择日期" readonly>
                </div>
                <br/>
                <label class="row-label" style="width: 150px">证件类型:</label>
                <div class="row-input required" style="width:200px">
                    <select data-toggle="selectpicker" name="credential_type">
                        <option value="1">身份证</option>
                    </select>
                </div>
                <label class="row-label" style="width: 150px">证件号:</label>
                <div class="row-input required" style="width:200px">
                    <input type="text" name="credential_number" value="{{ $employeeInfo['credential_number'] }}"
                           data-rule="required;length[~18]">
                </div>
                <label class="row-label" style="width: 150px">手机号:</label>
                <div class="row-input required" style="width:200px">
                    <input type="text" name="mobile" value="{{ $employeeInfo['mobile'] }}" data-rule="required;mobile">
                </div>
                <br/>
                <label class="row-label" style="width: 150px">家庭住址:</label>
                <div class="row-input required" style="width:550px">
                    <input type="text" name="address" value="{{ $employeeInfo['address'] }}" data-rule="required">
                </div>
                <br/>
                <label class="row-label" style="width: 150px">部门:</label>
                <div class="row-input required" style="width:200px">
                    <select data-toggle="selectpicker" id="oa_department_id" name="oa_department_id">
                        <option value="">请选择</option>
                        @foreach($departmentList as $department)
                            <option value="{{$department['id']}}"
                                    @if($department['id'] == $employeeInfo['oa_department_id']) selected @endif
                            >{{$department['name']}}</option>
                        @endforeach
                    </select>
                </div>
                <label class="row-label" style="width: 150px">岗位:</label>
                <div class="row-input required" style="width:200px">
                    <input type="text" name="position" value="{{ $employeeInfo['position'] }}" data-rule="required">
                </div>
                <label class="row-label" style="width: 150px">工号:</label>
                <div class="row-input required" style="width:200px">
                    <select data-toggle="selectpicker" id="employee_number" name="employee_number">
                        <option value="">请选择</option>
                        @foreach($employeeNumberList as $employeeNumber)
                            <option value="{{$employeeNumber['id']}}"
                                    @if($employeeNumber['id'] == $employeeInfo['employee_number']) selected @endif
                            >{{$employeeNumber['employee_number']}}</option>
                        @endforeach
                    </select>
                </div>
                <br/>
                <label class="row-label" style="width: 150px">人员类型:</label>
                <div class="row-input" style="width:200px">
                    <select data-toggle="selectpicker" name="type" disabled>
                        <option value="1" @if($employeeInfo['type'] == 1) selected @endif>正式工</option>
                        <option value="2" @if($employeeInfo['type'] == 2) selected @endif>临时工</option>
                    </select>
                </div>
                <br/>
                @if($employeeInfo['type'] == 1)
                    <label class="row-label" style="width: 150px">email:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="email" value="{{ $employeeInfo['email'] }}">
                    </div>
                    <label class="row-label" style="width: 150px">民族:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="ethnicity" value="{{ $employeeInfo['ethnicity'] }}">
                    </div>
                    <label class="row-label" style="width: 150px">学历:</label>
                    <div class="row-input required" style="width:200px">
                        <select data-toggle="selectpicker" id="education" name="education">
                            <option value="">请选择</option>
                            <option value="1" @if($employeeInfo['education'] == 1) selected @endif>初中及以下</option>
                            <option value="2" @if($employeeInfo['education'] == 2) selected @endif>高中</option>
                            <option value="3" @if($employeeInfo['education'] == 3) selected @endif>中技</option>
                            <option value="4" @if($employeeInfo['education'] == 4) selected @endif>中专</option>
                            <option value="5" @if($employeeInfo['education'] == 5) selected @endif>大专</option>
                            <option value="6" @if($employeeInfo['education'] == 6) selected @endif>本科</option>
                            <option value="7" @if($employeeInfo['education'] == 7) selected @endif>硕士</option>
                            <option value="8" @if($employeeInfo['education'] == 8) selected @endif>博士</option>
                            <option value="9" @if($employeeInfo['education'] == 9) selected @endif>MBA</option>
                        </select>
                    </div>
                    <br/>
                    <label class="row-label" style="width: 150px">婚姻状况:</label>
                    <div class="row-input" style="width:200px">
                        <select data-toggle="selectpicker" name="marital_status">
                            <option value="0" @if($employeeInfo['marital_status'] == 0) selected @endif>不明</option>
                            <option value="1" @if($employeeInfo['marital_status'] == 1) selected @endif>未婚</option>
                            <option value="2" @if($employeeInfo['marital_status'] == 2) selected @endif>已婚</option>
                            <option value="3" @if($employeeInfo['marital_status'] == 3) selected @endif>离异</option>
                        </select>
                    </div>
                    <label class="row-label" style="width: 150px">户籍类型:</label>
                    <div class="row-input" style="width:200px">
                        <select data-toggle="selectpicker" name="household_registratio_type">
                            <option value="0" @if($employeeInfo['household_registratio_type'] == 0) selected @endif>
                                不明
                            </option>
                            <option value="1" @if($employeeInfo['household_registratio_type'] == 1) selected @endif>
                                农业户口
                            </option>
                            <option value="2" @if($employeeInfo['household_registratio_type'] == 2) selected @endif>
                                非农户口
                            </option>
                        </select>
                    </div>
                    <br/>
                    <label class="row-label" style="width: 150px">人员来源:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="personnel_sources" value="{{ $employeeInfo['personnel_sources'] }}">
                    </div>
                    <br/>
                    <label class="row-label" style="width: 150px">健康证有效期:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="health_certificate_term" data-toggle="datepicker"
                               value="{{ $employeeInfo['health_certificate_term'] }}"
                               placeholder="点击日历选择日期" readonly>
                    </div>
                    <br/>
                    <label class="row-label" style="width: 150px">通讯录头像:</label>
                    <div class="row-input" style="width:200px">
                        <input type="file" data-name="profile_photo_url" data-toggle="webuploader" data-options="
                        {
                            pick: {label: '点击选择图片'},
                            server: '/admin/personnel/profile-photo-upload',
                            fileNumLimit: 1,
                            formData: {_token:'{{csrf_token()}}'},
                            required: false,
                            uploaded: '{{ $employeeInfo['profile_photo_url'] }}',
                            basePath: '',
                            accept: {
                                title: '图片',
                                extensions: 'jpg,png',
                                mimeTypes: '.jpg,.png'
                            }
                        }">
                    </div>
                    <br>
                    <label class="row-label" style="width: 150px">备注:</label>
                    <div class="row-input" style="width:200px">
                        <textarea name="note">{{ $employeeInfo['note'] }}</textarea>
                    </div>
                    <br/>
                    <label class="row-label" style="width: 150px">公积金:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="accumulation_fund" value="{{$employeeInfo['accumulation_fund']}}">
                    </div>
                    <label class="row-label" style="width: 150px">公积金基数:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="accumulation_fund_base"
                               value="{{$employeeInfo['accumulation_fund_base']}}">
                    </div>
                    <label class="row-label" style="width: 150px">公积金调整时间:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="accumulation_fund_adjust_time" data-toggle="datepicker"
                               value="{{$employeeInfo['accumulation_fund_adjust_time']}}" placeholder="点击日历选择日期"
                               readonly>
                    </div>
                    <br/>
                    <label class="row-label" style="width: 150px">社保基数:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="social_security_base"
                               value="{{$employeeInfo['social_security_base']}}">
                    </div>
                    <label class="row-label" style="width: 150px">参保基数调整时间:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="insured_adjust_time" data-toggle="datepicker"
                               value="{{$employeeInfo['insured_adjust_time']}}" placeholder="点击日历选择日期" readonly>
                    </div>
                    <br/>
                @endif
                @if($employeeInfo['type'] == 2)
                    <label class="row-label" style="width: 150px">到厂日期:</label>
                    <div class="row-input" style="width:200px">
                        <input type="text" name="start_time" data-toggle="datepicker"
                               value="{{ $employeeInfo['start_time'] }}"
                               placeholder="点击日历选择日期" readonly>
                    </div>
                    <br/>
                @endif
            </div>
        </div>
    </form>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li>
            <button type="button" class="btn-close" data-icon="close">取消</button>
        </li>
        <li>
            <button type="submit" class="btn-default" data-icon="save">保存</button>
        </li>
    </ul>
</div>
<script>
    function refreshAddressList() {
        $('#company-address-list').datagrid('refresh', true);
    }
    function checkAddressListMemberData() {
        var role = $.CurrentNavtab.find("#role_name").val();
        var department = $.CurrentNavtab.find("#oa_department_id").val();
        var sex = $.CurrentNavtab.find("#sex").val();
        var education = $.CurrentNavtab.find("#education").val();
        var employee_number = $.CurrentNavtab.find("#employee_number").val();
        var uploaded_url = $.CurrentNavtab.find("#uploader .uploaded .title").html();
        if (role) {
            if (department) {
                if (sex) {
                    if (education) {
                        if (employee_number) {
                            if ($.CurrentNavtab.find("input[name='image_url']").val()) {
                                return true;
                            } else if (uploaded_url) {
                                $.CurrentNavtab.find("#addBox").append('<input type="text" name="image_url" value="' + uploaded_url + '">');
                            }
                            return true;
                        } else {
                            BJUI.alertmsg('info', '请选择工号');
                        }
                    } else {
                        BJUI.alertmsg('info', '请选择学历');
                    }
                } else {
                    BJUI.alertmsg('info', '请选择性别');
                }
            } else {
                BJUI.alertmsg('info', '请选择部门');
            }
        } else {
            BJUI.alertmsg('info', '请选择角色');
        }
    }
</script>
<style>
    .ilabel {
        display: none;
    }
</style>